- /* sifdivnw.cpp by K.Tsuru */
- // function ID = 427 BRADIX
- /**************************************************************
- SInteger class's friend function.
- It provides the quotient m/n and remainder m%n.
- The Newton'method division is used after the radix conversion
- to SLong.It is not so fast because the radix conversion spends
- time.
- ***************************************************************/
- #ifndef SN_H
- #include "sn.h"
- #endif
- void NewtonIIDiv(const SInteger& m, const SInteger& n, Ldiv_t& r, bool needRem){
- SLong M, N;
- int dm = M.LLDivMode();
- M = m.ConvToDec(); N = n.ConvToDec(); //radix conversion
- M.UseNewtonLLDiv();
- r = LLDiv(M, N, needRem);
- /*
- A statement
- r.rem=ConvToBin(r.quot);
- cannot be used, because it is interpreted as the substitution "SLong=SInteger".
- Then the constructor of "Ldiv_t" structure is used.
- */
- SInteger tmp; // version 2.20
- if(needRem) r = Ldiv_t( tmp.ConvToBin(r.quot), tmp.ConvToBin(r.rem) ); //inverse conversion
- else r = Ldiv_t( tmp.ConvToBin(r.quot) );
- if(dm == M.Knuth) M.UseKnuthLLDiv();
- }
sifdivnw.cpp : last modifiled at 2016/08/03 16:32:36(1,079 bytes)
created at 2016/04/25 14:53:17
The creation time of this html file is 2017/10/25 11:09:45 (Wed Oct 25 11:09:45 2017).